package com.yang.api.advice;

import com.yang.api.utils.R;
import com.yang.api.vo.ResultVO;
import com.yang.common.exception.ApiException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author yangyongsheng
 * @date 2024/7/2 17:42
 * @description
 */
@RestControllerAdvice
public class ApiExceptionHandler {

    /**
     * 对抛出ApiException的异常进行处理，返回ResultVO
     * @param ex
     * @return
     */
    @ExceptionHandler(ApiException.class)
    public ResultVO apiException(ApiException ex){
        return R.error(ex);
    }
}
